<template>
	<view>
		<view class="loading-box">
			<u-loading mode="flower" size="100"></u-loading>
			<view class="u-p-t-30"><text class="u-font-32 u-tips-color">加载中，请稍后...</text></view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	
	export default {
		data() {
			return {
				
			}
		},
		computed: {
			...mapState({
				Authorization: state => state.Authorization,
				webSetting: state => state.webSetting,
				userType: state => state.userType
			})
		},
		onLoad() {
			if(this.Authorization != ''){
				// // 获取lifeData并检查是否存在
				// const lifeData = uni.getStorageSync('lifeData');
				// if (!lifeData || lifeData.userType === undefined || lifeData.userType === null) {
				// 	console.warn('lifeData or userType not found, redirecting to default page');
				// 	uni.switchTab({
				// 		url: '/pages/index/index'
				// 	});
				// 	return;
				// }
				
				let type = uni.getStorageSync('selectUserType') || 1

				switch (type){
					case 1:
						// 用户
						uni.switchTab({
							url: '/pages/index/index'
						})
						break;
					case 3:
						// 小哥
						uni.reLaunch({
							url: '/pages/brother/index/index'
						})
						break;
					case 4:
						// 站点
						uni.reLaunch({
							url: '/pages/shop/index/index'
						})
						break;
					case 5:
						// 运营商管理员
						uni.reLaunch({
							url: '/pages/admin/index/index'
						})
						break;
					case 6:
						// 加盟商管理员
						uni.reLaunch({
							url: '/pages/admin/franchise/index/index'
						})
						break;
					default:
						uni.switchTab({
							url: '/pages/index/index'
						})
						break;
				}
			}else{
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		},
		methods: {
			
		}
	}
</script>

<style lang="scss" scoped>
	.loading-box{
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}
</style>
